﻿using System;
using System.ComponentModel;
using System.IO;
using System.Runtime.Serialization;

namespace HalconDotNet
{
	/// <summary>Represents an instance of a training result for the component-based matching.</summary>
	// Token: 0x02000029 RID: 41
	[Serializable]
	public class HComponentTraining : HHandle, ISerializable, ICloneable
	{
		// Token: 0x0600038E RID: 910 RVA: 0x0000883B File Offset: 0x00006A3B
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HComponentTraining() : base(HHandleBase.UNDEF)
		{
		}

		// Token: 0x0600038F RID: 911 RVA: 0x000154CA File Offset: 0x000136CA
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HComponentTraining(IntPtr handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000390 RID: 912 RVA: 0x000154D9 File Offset: 0x000136D9
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HComponentTraining(HHandle handle) : base(handle)
		{
			this.AssertSemType();
		}

		// Token: 0x06000391 RID: 913 RVA: 0x000154E8 File Offset: 0x000136E8
		private void AssertSemType()
		{
			base.AssertSemType("component_training");
		}

		// Token: 0x06000392 RID: 914 RVA: 0x000154F5 File Offset: 0x000136F5
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HComponentTraining obj)
		{
			obj = new HComponentTraining(HHandleBase.UNDEF);
			return obj.Load(proc, parIndex, err);
		}

		// Token: 0x06000393 RID: 915 RVA: 0x00015510 File Offset: 0x00013710
		internal static int LoadNew(IntPtr proc, int parIndex, int err, out HComponentTraining[] obj)
		{
			HTuple htuple;
			err = HTuple.LoadNew(proc, parIndex, err, out htuple);
			obj = new HComponentTraining[htuple.Length];
			for (int i = 0; i < htuple.Length; i++)
			{
				obj[i] = new HComponentTraining(HalconAPI.IsLegacyHandleMode() ? htuple[i].IP : htuple[i].H);
			}
			htuple.Dispose();
			return err;
		}

		/// <summary>
		///   Train components and relations for the component-based matching.
		///   Modified instance represents: Handle of the training result.
		/// </summary>
		/// <param name="modelImage">Input image from which the shape models of the initial components should be created.</param>
		/// <param name="initialComponents">Contour regions or enclosing regions of the initial components.</param>
		/// <param name="trainingImages">Training images that are used for training the model components.</param>
		/// <param name="modelComponents">Contour regions of rigid model components.</param>
		/// <param name="contrastLow">Lower hysteresis threshold for the contrast of the initial components in the image. Default: "auto"</param>
		/// <param name="contrastHigh">Upper hysteresis threshold for the contrast of the initial components in the image. Default: "auto"</param>
		/// <param name="minSize">Minimum size of connected contour regions. Default: "auto"</param>
		/// <param name="minScore">Minimum score of the instances of the initial components to be found. Default: 0.5</param>
		/// <param name="searchRowTol">Search tolerance in row direction. Default: -1</param>
		/// <param name="searchColumnTol">Search tolerance in column direction. Default: -1</param>
		/// <param name="searchAngleTol">Angle search tolerance. Default: -1</param>
		/// <param name="trainingEmphasis">Decision whether the training emphasis should lie on a fast computation or on a high robustness. Default: "speed"</param>
		/// <param name="ambiguityCriterion">Criterion for solving ambiguous matches of the initial components in the training images. Default: "rigidity"</param>
		/// <param name="maxContourOverlap">Maximum contour overlap of the found initial components in a training image. Default: 0.2</param>
		/// <param name="clusterThreshold">Threshold for clustering the initial components. Default: 0.5</param>
		// Token: 0x06000394 RID: 916 RVA: 0x00015580 File Offset: 0x00013780
		public HComponentTraining(HImage modelImage, HRegion initialComponents, HImage trainingImages, out HRegion modelComponents, HTuple contrastLow, HTuple contrastHigh, HTuple minSize, HTuple minScore, HTuple searchRowTol, HTuple searchColumnTol, HTuple searchAngleTol, string trainingEmphasis, string ambiguityCriterion, double maxContourOverlap, double clusterThreshold)
		{
			IntPtr proc = HalconAPI.PreCall(1017);
			HalconAPI.Store(proc, 1, modelImage);
			HalconAPI.Store(proc, 2, initialComponents);
			HalconAPI.Store(proc, 3, trainingImages);
			HalconAPI.Store(proc, 0, contrastLow);
			HalconAPI.Store(proc, 1, contrastHigh);
			HalconAPI.Store(proc, 2, minSize);
			HalconAPI.Store(proc, 3, minScore);
			HalconAPI.Store(proc, 4, searchRowTol);
			HalconAPI.Store(proc, 5, searchColumnTol);
			HalconAPI.Store(proc, 6, searchAngleTol);
			HalconAPI.StoreS(proc, 7, trainingEmphasis);
			HalconAPI.StoreS(proc, 8, ambiguityCriterion);
			HalconAPI.StoreD(proc, 9, maxContourOverlap);
			HalconAPI.StoreD(proc, 10, clusterThreshold);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(contrastLow);
			HalconAPI.UnpinTuple(contrastHigh);
			HalconAPI.UnpinTuple(minSize);
			HalconAPI.UnpinTuple(minScore);
			HalconAPI.UnpinTuple(searchRowTol);
			HalconAPI.UnpinTuple(searchColumnTol);
			HalconAPI.UnpinTuple(searchAngleTol);
			num = base.Load(proc, 0, num);
			num = HRegion.LoadNew(proc, 1, num, out modelComponents);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(modelImage);
			GC.KeepAlive(initialComponents);
			GC.KeepAlive(trainingImages);
		}

		/// <summary>
		///   Train components and relations for the component-based matching.
		///   Modified instance represents: Handle of the training result.
		/// </summary>
		/// <param name="modelImage">Input image from which the shape models of the initial components should be created.</param>
		/// <param name="initialComponents">Contour regions or enclosing regions of the initial components.</param>
		/// <param name="trainingImages">Training images that are used for training the model components.</param>
		/// <param name="modelComponents">Contour regions of rigid model components.</param>
		/// <param name="contrastLow">Lower hysteresis threshold for the contrast of the initial components in the image. Default: "auto"</param>
		/// <param name="contrastHigh">Upper hysteresis threshold for the contrast of the initial components in the image. Default: "auto"</param>
		/// <param name="minSize">Minimum size of connected contour regions. Default: "auto"</param>
		/// <param name="minScore">Minimum score of the instances of the initial components to be found. Default: 0.5</param>
		/// <param name="searchRowTol">Search tolerance in row direction. Default: -1</param>
		/// <param name="searchColumnTol">Search tolerance in column direction. Default: -1</param>
		/// <param name="searchAngleTol">Angle search tolerance. Default: -1</param>
		/// <param name="trainingEmphasis">Decision whether the training emphasis should lie on a fast computation or on a high robustness. Default: "speed"</param>
		/// <param name="ambiguityCriterion">Criterion for solving ambiguous matches of the initial components in the training images. Default: "rigidity"</param>
		/// <param name="maxContourOverlap">Maximum contour overlap of the found initial components in a training image. Default: 0.2</param>
		/// <param name="clusterThreshold">Threshold for clustering the initial components. Default: 0.5</param>
		// Token: 0x06000395 RID: 917 RVA: 0x00015698 File Offset: 0x00013898
		public HComponentTraining(HImage modelImage, HRegion initialComponents, HImage trainingImages, out HRegion modelComponents, int contrastLow, int contrastHigh, int minSize, double minScore, int searchRowTol, int searchColumnTol, double searchAngleTol, string trainingEmphasis, string ambiguityCriterion, double maxContourOverlap, double clusterThreshold)
		{
			IntPtr proc = HalconAPI.PreCall(1017);
			HalconAPI.Store(proc, 1, modelImage);
			HalconAPI.Store(proc, 2, initialComponents);
			HalconAPI.Store(proc, 3, trainingImages);
			HalconAPI.StoreI(proc, 0, contrastLow);
			HalconAPI.StoreI(proc, 1, contrastHigh);
			HalconAPI.StoreI(proc, 2, minSize);
			HalconAPI.StoreD(proc, 3, minScore);
			HalconAPI.StoreI(proc, 4, searchRowTol);
			HalconAPI.StoreI(proc, 5, searchColumnTol);
			HalconAPI.StoreD(proc, 6, searchAngleTol);
			HalconAPI.StoreS(proc, 7, trainingEmphasis);
			HalconAPI.StoreS(proc, 8, ambiguityCriterion);
			HalconAPI.StoreD(proc, 9, maxContourOverlap);
			HalconAPI.StoreD(proc, 10, clusterThreshold);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			num = HRegion.LoadNew(proc, 1, num, out modelComponents);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(modelImage);
			GC.KeepAlive(initialComponents);
			GC.KeepAlive(trainingImages);
		}

		// Token: 0x06000396 RID: 918 RVA: 0x00015780 File Offset: 0x00013980
		void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = this.SerializeTrainingComponents();
			byte[] value = hserializedItem;
			hserializedItem.Dispose();
			info.AddValue("data", value, typeof(byte[]));
		}

		// Token: 0x06000397 RID: 919 RVA: 0x000157B8 File Offset: 0x000139B8
		[EditorBrowsable(EditorBrowsableState.Never)]
		public HComponentTraining(SerializationInfo info, StreamingContext context)
		{
			HSerializedItem hserializedItem = new HSerializedItem((byte[])info.GetValue("data", typeof(byte[])));
			this.DeserializeTrainingComponents(hserializedItem);
			hserializedItem.Dispose();
		}

		/// <summary>Serialize object to binary stream in HALCON format</summary>
		// Token: 0x06000398 RID: 920 RVA: 0x000157F8 File Offset: 0x000139F8
		public new void Serialize(Stream stream)
		{
			HSerializedItem hserializedItem = this.SerializeTrainingComponents();
			hserializedItem.Serialize(stream);
			hserializedItem.Dispose();
		}

		/// <summary>Deserialize object from binary stream in HALCON format</summary>
		// Token: 0x06000399 RID: 921 RVA: 0x0001580C File Offset: 0x00013A0C
		public new static HComponentTraining Deserialize(Stream stream)
		{
			HComponentTraining hcomponentTraining = new HComponentTraining();
			HSerializedItem hserializedItem = HSerializedItem.Deserialize(stream);
			hcomponentTraining.DeserializeTrainingComponents(hserializedItem);
			hserializedItem.Dispose();
			return hcomponentTraining;
		}

		// Token: 0x0600039A RID: 922 RVA: 0x00015832 File Offset: 0x00013A32
		object ICloneable.Clone()
		{
			return this.Clone();
		}

		// Token: 0x0600039B RID: 923 RVA: 0x0001583C File Offset: 0x00013A3C
		public new HComponentTraining Clone()
		{
			HSerializedItem hserializedItem = this.SerializeTrainingComponents();
			HComponentTraining hcomponentTraining = new HComponentTraining();
			hcomponentTraining.DeserializeTrainingComponents(hserializedItem);
			hserializedItem.Dispose();
			return hcomponentTraining;
		}

		/// <summary>
		///   Prepare a component model for matching based on trained components.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="angleStart">Smallest rotation of the component model. Default: -0.39</param>
		/// <param name="angleExtent">Extent of the rotation of the component model. Default: 0.79</param>
		/// <param name="minContrastComp">Minimum contrast of the components in the search images. Default: "auto"</param>
		/// <param name="minScoreComp">Minimum score of the instances of the components to be found. Default: 0.5</param>
		/// <param name="numLevelsComp">Maximum number of pyramid levels for the components. Default: "auto"</param>
		/// <param name="angleStepComp">Step length of the angles (resolution) for the components. Default: "auto"</param>
		/// <param name="optimizationComp">Kind of optimization for the components. Default: "auto"</param>
		/// <param name="metricComp">Match metric used for the components. Default: "use_polarity"</param>
		/// <param name="pregenerationComp">Complete pregeneration of the shape models for the components if equal to 'true'. Default: "false"</param>
		/// <param name="rootRanking">Ranking of the model components expressing the suitability to act as the root component.</param>
		/// <returns>Handle of the component model.</returns>
		// Token: 0x0600039C RID: 924 RVA: 0x00015864 File Offset: 0x00013A64
		public HComponentModel CreateTrainedComponentModel(double angleStart, double angleExtent, HTuple minContrastComp, HTuple minScoreComp, HTuple numLevelsComp, HTuple angleStepComp, string optimizationComp, HTuple metricComp, HTuple pregenerationComp, out HTuple rootRanking)
		{
			IntPtr proc = HalconAPI.PreCall(1005);
			base.Store(proc, 0);
			HalconAPI.StoreD(proc, 1, angleStart);
			HalconAPI.StoreD(proc, 2, angleExtent);
			HalconAPI.Store(proc, 3, minContrastComp);
			HalconAPI.Store(proc, 4, minScoreComp);
			HalconAPI.Store(proc, 5, numLevelsComp);
			HalconAPI.Store(proc, 6, angleStepComp);
			HalconAPI.StoreS(proc, 7, optimizationComp);
			HalconAPI.Store(proc, 8, metricComp);
			HalconAPI.Store(proc, 9, pregenerationComp);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(minContrastComp);
			HalconAPI.UnpinTuple(minScoreComp);
			HalconAPI.UnpinTuple(numLevelsComp);
			HalconAPI.UnpinTuple(angleStepComp);
			HalconAPI.UnpinTuple(metricComp);
			HalconAPI.UnpinTuple(pregenerationComp);
			HComponentModel result;
			num = HComponentModel.LoadNew(proc, 0, num, out result);
			num = HTuple.LoadNew(proc, 1, HTupleType.INTEGER, num, out rootRanking);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Prepare a component model for matching based on trained components.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="angleStart">Smallest rotation of the component model. Default: -0.39</param>
		/// <param name="angleExtent">Extent of the rotation of the component model. Default: 0.79</param>
		/// <param name="minContrastComp">Minimum contrast of the components in the search images. Default: "auto"</param>
		/// <param name="minScoreComp">Minimum score of the instances of the components to be found. Default: 0.5</param>
		/// <param name="numLevelsComp">Maximum number of pyramid levels for the components. Default: "auto"</param>
		/// <param name="angleStepComp">Step length of the angles (resolution) for the components. Default: "auto"</param>
		/// <param name="optimizationComp">Kind of optimization for the components. Default: "auto"</param>
		/// <param name="metricComp">Match metric used for the components. Default: "use_polarity"</param>
		/// <param name="pregenerationComp">Complete pregeneration of the shape models for the components if equal to 'true'. Default: "false"</param>
		/// <param name="rootRanking">Ranking of the model components expressing the suitability to act as the root component.</param>
		/// <returns>Handle of the component model.</returns>
		// Token: 0x0600039D RID: 925 RVA: 0x00015938 File Offset: 0x00013B38
		public HComponentModel CreateTrainedComponentModel(double angleStart, double angleExtent, int minContrastComp, double minScoreComp, int numLevelsComp, double angleStepComp, string optimizationComp, string metricComp, string pregenerationComp, out int rootRanking)
		{
			IntPtr proc = HalconAPI.PreCall(1005);
			base.Store(proc, 0);
			HalconAPI.StoreD(proc, 1, angleStart);
			HalconAPI.StoreD(proc, 2, angleExtent);
			HalconAPI.StoreI(proc, 3, minContrastComp);
			HalconAPI.StoreD(proc, 4, minScoreComp);
			HalconAPI.StoreI(proc, 5, numLevelsComp);
			HalconAPI.StoreD(proc, 6, angleStepComp);
			HalconAPI.StoreS(proc, 7, optimizationComp);
			HalconAPI.StoreS(proc, 8, metricComp);
			HalconAPI.StoreS(proc, 9, pregenerationComp);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HComponentModel result;
			num = HComponentModel.LoadNew(proc, 0, num, out result);
			num = HalconAPI.LoadI(proc, 1, num, out rootRanking);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Free the memory of a component training result.
		///   Instance represents: Handle of the training result.
		/// </summary>
		// Token: 0x0600039E RID: 926 RVA: 0x000159E4 File Offset: 0x00013BE4
		public void ClearTrainingComponents()
		{
			IntPtr proc = HalconAPI.PreCall(1007);
			base.Store(proc, 0);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Return the relations between the model components that are contained in a training result.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="referenceComponent">Index of reference component.</param>
		/// <param name="image">Image for which the component relations are to be returned. Default: "model_image"</param>
		/// <param name="row">Row coordinate of the center of the rectangle representing the relation.</param>
		/// <param name="column">Column index of the center of the rectangle representing the relation.</param>
		/// <param name="phi">Orientation of the rectangle representing the relation (radians).</param>
		/// <param name="length1">First radius (half length) of the rectangle representing the relation.</param>
		/// <param name="length2">Second radius (half width) of the rectangle representing the relation.</param>
		/// <param name="angleStart">Smallest relative orientation angle.</param>
		/// <param name="angleExtent">Extent of the relative orientation angles.</param>
		/// <returns>Region representation of the relations.</returns>
		// Token: 0x0600039F RID: 927 RVA: 0x00015A18 File Offset: 0x00013C18
		public HRegion GetComponentRelations(int referenceComponent, HTuple image, out HTuple row, out HTuple column, out HTuple phi, out HTuple length1, out HTuple length2, out HTuple angleStart, out HTuple angleExtent)
		{
			IntPtr proc = HalconAPI.PreCall(1008);
			base.Store(proc, 0);
			HalconAPI.StoreI(proc, 1, referenceComponent);
			HalconAPI.Store(proc, 2, image);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			HalconAPI.InitOCT(proc, 4);
			HalconAPI.InitOCT(proc, 5);
			HalconAPI.InitOCT(proc, 6);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(image);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			num = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, num, out row);
			num = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, num, out column);
			num = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, num, out phi);
			num = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, num, out length1);
			num = HTuple.LoadNew(proc, 4, HTupleType.DOUBLE, num, out length2);
			num = HTuple.LoadNew(proc, 5, HTupleType.DOUBLE, num, out angleStart);
			num = HTuple.LoadNew(proc, 6, HTupleType.DOUBLE, num, out angleExtent);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Return the relations between the model components that are contained in a training result.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="referenceComponent">Index of reference component.</param>
		/// <param name="image">Image for which the component relations are to be returned. Default: "model_image"</param>
		/// <param name="row">Row coordinate of the center of the rectangle representing the relation.</param>
		/// <param name="column">Column index of the center of the rectangle representing the relation.</param>
		/// <param name="phi">Orientation of the rectangle representing the relation (radians).</param>
		/// <param name="length1">First radius (half length) of the rectangle representing the relation.</param>
		/// <param name="length2">Second radius (half width) of the rectangle representing the relation.</param>
		/// <param name="angleStart">Smallest relative orientation angle.</param>
		/// <param name="angleExtent">Extent of the relative orientation angles.</param>
		/// <returns>Region representation of the relations.</returns>
		// Token: 0x060003A0 RID: 928 RVA: 0x00015B04 File Offset: 0x00013D04
		public HRegion GetComponentRelations(int referenceComponent, string image, out double row, out double column, out double phi, out double length1, out double length2, out double angleStart, out double angleExtent)
		{
			IntPtr proc = HalconAPI.PreCall(1008);
			base.Store(proc, 0);
			HalconAPI.StoreI(proc, 1, referenceComponent);
			HalconAPI.StoreS(proc, 2, image);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			HalconAPI.InitOCT(proc, 4);
			HalconAPI.InitOCT(proc, 5);
			HalconAPI.InitOCT(proc, 6);
			int num = HalconAPI.CallProcedure(proc);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out phi);
			num = HalconAPI.LoadD(proc, 3, num, out length1);
			num = HalconAPI.LoadD(proc, 4, num, out length2);
			num = HalconAPI.LoadD(proc, 5, num, out angleStart);
			num = HalconAPI.LoadD(proc, 6, num, out angleExtent);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Return the initial or model components in a certain image.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="components">Type of returned components or index of an initial component. Default: "model_components"</param>
		/// <param name="image">Image for which the components are to be returned. Default: "model_image"</param>
		/// <param name="markOrientation">Mark the orientation of the components. Default: "false"</param>
		/// <param name="row">Row coordinate of the found instances of all initial components or model components.</param>
		/// <param name="column">Column coordinate of the found instances of all initial components or model components.</param>
		/// <param name="angle">Rotation angle of the found instances of all components.</param>
		/// <param name="score">Score of the found instances of all components.</param>
		/// <returns>Contour regions of the initial components or of the model components.</returns>
		// Token: 0x060003A1 RID: 929 RVA: 0x00015BE0 File Offset: 0x00013DE0
		public HRegion GetTrainingComponents(HTuple components, HTuple image, string markOrientation, out HTuple row, out HTuple column, out HTuple angle, out HTuple score)
		{
			IntPtr proc = HalconAPI.PreCall(1009);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, components);
			HalconAPI.Store(proc, 2, image);
			HalconAPI.StoreS(proc, 3, markOrientation);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(components);
			HalconAPI.UnpinTuple(image);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			num = HTuple.LoadNew(proc, 0, HTupleType.DOUBLE, num, out row);
			num = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, num, out column);
			num = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, num, out angle);
			num = HTuple.LoadNew(proc, 3, HTupleType.DOUBLE, num, out score);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Return the initial or model components in a certain image.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="components">Type of returned components or index of an initial component. Default: "model_components"</param>
		/// <param name="image">Image for which the components are to be returned. Default: "model_image"</param>
		/// <param name="markOrientation">Mark the orientation of the components. Default: "false"</param>
		/// <param name="row">Row coordinate of the found instances of all initial components or model components.</param>
		/// <param name="column">Column coordinate of the found instances of all initial components or model components.</param>
		/// <param name="angle">Rotation angle of the found instances of all components.</param>
		/// <param name="score">Score of the found instances of all components.</param>
		/// <returns>Contour regions of the initial components or of the model components.</returns>
		// Token: 0x060003A2 RID: 930 RVA: 0x00015C9C File Offset: 0x00013E9C
		public HRegion GetTrainingComponents(string components, string image, string markOrientation, out double row, out double column, out double angle, out double score)
		{
			IntPtr proc = HalconAPI.PreCall(1009);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, components);
			HalconAPI.StoreS(proc, 2, image);
			HalconAPI.StoreS(proc, 3, markOrientation);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			HalconAPI.InitOCT(proc, 2);
			HalconAPI.InitOCT(proc, 3);
			int num = HalconAPI.CallProcedure(proc);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			num = HalconAPI.LoadD(proc, 0, num, out row);
			num = HalconAPI.LoadD(proc, 1, num, out column);
			num = HalconAPI.LoadD(proc, 2, num, out angle);
			num = HalconAPI.LoadD(proc, 3, num, out score);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Modify the relations within a training result.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="referenceComponent">Model component(s) relative to which the movement(s) should be modified. Default: "all"</param>
		/// <param name="toleranceComponent">Model component(s) of which the relative movement(s) should be modified. Default: "all"</param>
		/// <param name="positionTolerance">Change of the position relation in pixels.</param>
		/// <param name="angleTolerance">Change of the orientation relation in radians.</param>
		// Token: 0x060003A3 RID: 931 RVA: 0x00015D48 File Offset: 0x00013F48
		public void ModifyComponentRelations(HTuple referenceComponent, HTuple toleranceComponent, HTuple positionTolerance, HTuple angleTolerance)
		{
			IntPtr proc = HalconAPI.PreCall(1010);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, referenceComponent);
			HalconAPI.Store(proc, 2, toleranceComponent);
			HalconAPI.Store(proc, 3, positionTolerance);
			HalconAPI.Store(proc, 4, angleTolerance);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(referenceComponent);
			HalconAPI.UnpinTuple(toleranceComponent);
			HalconAPI.UnpinTuple(positionTolerance);
			HalconAPI.UnpinTuple(angleTolerance);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Modify the relations within a training result.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="referenceComponent">Model component(s) relative to which the movement(s) should be modified. Default: "all"</param>
		/// <param name="toleranceComponent">Model component(s) of which the relative movement(s) should be modified. Default: "all"</param>
		/// <param name="positionTolerance">Change of the position relation in pixels.</param>
		/// <param name="angleTolerance">Change of the orientation relation in radians.</param>
		// Token: 0x060003A4 RID: 932 RVA: 0x00015DB8 File Offset: 0x00013FB8
		public void ModifyComponentRelations(string referenceComponent, string toleranceComponent, double positionTolerance, double angleTolerance)
		{
			IntPtr proc = HalconAPI.PreCall(1010);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, referenceComponent);
			HalconAPI.StoreS(proc, 2, toleranceComponent);
			HalconAPI.StoreD(proc, 3, positionTolerance);
			HalconAPI.StoreD(proc, 4, angleTolerance);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Deserialize a component training result.
		///   Modified instance represents: Handle of the training result.
		/// </summary>
		/// <param name="serializedItemHandle">Handle of the serialized item.</param>
		// Token: 0x060003A5 RID: 933 RVA: 0x00015E10 File Offset: 0x00014010
		public void DeserializeTrainingComponents(HSerializedItem serializedItemHandle)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1011);
			HalconAPI.Store(proc, 0, serializedItemHandle);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(serializedItemHandle);
		}

		/// <summary>
		///   Serialize a component training result.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <returns>Handle of the serialized item.</returns>
		// Token: 0x060003A6 RID: 934 RVA: 0x00015E64 File Offset: 0x00014064
		public HSerializedItem SerializeTrainingComponents()
		{
			IntPtr proc = HalconAPI.PreCall(1012);
			base.Store(proc, 0);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			HSerializedItem result;
			num = HSerializedItem.LoadNew(proc, 0, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Read a component training result from a file.
		///   Modified instance represents: Handle of the training result.
		/// </summary>
		/// <param name="fileName">File name.</param>
		// Token: 0x060003A7 RID: 935 RVA: 0x00015EAC File Offset: 0x000140AC
		public void ReadTrainingComponents(string fileName)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1013);
			HalconAPI.StoreS(proc, 0, fileName);
			HalconAPI.InitOCT(proc, 0);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Write a component training result to a file.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="fileName">File name.</param>
		// Token: 0x060003A8 RID: 936 RVA: 0x00015EF8 File Offset: 0x000140F8
		public void WriteTrainingComponents(string fileName)
		{
			IntPtr proc = HalconAPI.PreCall(1014);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, fileName);
			int procResult = HalconAPI.CallProcedure(proc);
			HalconAPI.PostCall(proc, procResult);
			GC.KeepAlive(this);
		}

		/// <summary>
		///   Adopt new parameters that are used to create the model components into the training result.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="trainingImages">Training images that were used for training the model components.</param>
		/// <param name="ambiguityCriterion">Criterion for solving the ambiguities. Default: "rigidity"</param>
		/// <param name="maxContourOverlap">Maximum contour overlap of the found initial components. Default: 0.2</param>
		/// <param name="clusterThreshold">Threshold for clustering the initial components. Default: 0.5</param>
		/// <returns>Contour regions of rigid model components.</returns>
		// Token: 0x060003A9 RID: 937 RVA: 0x00015F34 File Offset: 0x00014134
		public HRegion ClusterModelComponents(HImage trainingImages, string ambiguityCriterion, double maxContourOverlap, double clusterThreshold)
		{
			IntPtr proc = HalconAPI.PreCall(1015);
			base.Store(proc, 0);
			HalconAPI.Store(proc, 1, trainingImages);
			HalconAPI.StoreS(proc, 1, ambiguityCriterion);
			HalconAPI.StoreD(proc, 2, maxContourOverlap);
			HalconAPI.StoreD(proc, 3, clusterThreshold);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(trainingImages);
			return result;
		}

		/// <summary>
		///   Inspect the rigid model components obtained from the training.
		///   Instance represents: Handle of the training result.
		/// </summary>
		/// <param name="ambiguityCriterion">Criterion for solving the ambiguities. Default: "rigidity"</param>
		/// <param name="maxContourOverlap">Maximum contour overlap of the found initial components. Default: 0.2</param>
		/// <param name="clusterThreshold">Threshold for clustering the initial components. Default: 0.5</param>
		/// <returns>Contour regions of rigid model components.</returns>
		// Token: 0x060003AA RID: 938 RVA: 0x00015FA4 File Offset: 0x000141A4
		public HRegion InspectClusteredComponents(string ambiguityCriterion, double maxContourOverlap, double clusterThreshold)
		{
			IntPtr proc = HalconAPI.PreCall(1016);
			base.Store(proc, 0);
			HalconAPI.StoreS(proc, 1, ambiguityCriterion);
			HalconAPI.StoreD(proc, 2, maxContourOverlap);
			HalconAPI.StoreD(proc, 3, clusterThreshold);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			return result;
		}

		/// <summary>
		///   Train components and relations for the component-based matching.
		///   Modified instance represents: Handle of the training result.
		/// </summary>
		/// <param name="modelImage">Input image from which the shape models of the initial components should be created.</param>
		/// <param name="initialComponents">Contour regions or enclosing regions of the initial components.</param>
		/// <param name="trainingImages">Training images that are used for training the model components.</param>
		/// <param name="contrastLow">Lower hysteresis threshold for the contrast of the initial components in the image. Default: "auto"</param>
		/// <param name="contrastHigh">Upper hysteresis threshold for the contrast of the initial components in the image. Default: "auto"</param>
		/// <param name="minSize">Minimum size of connected contour regions. Default: "auto"</param>
		/// <param name="minScore">Minimum score of the instances of the initial components to be found. Default: 0.5</param>
		/// <param name="searchRowTol">Search tolerance in row direction. Default: -1</param>
		/// <param name="searchColumnTol">Search tolerance in column direction. Default: -1</param>
		/// <param name="searchAngleTol">Angle search tolerance. Default: -1</param>
		/// <param name="trainingEmphasis">Decision whether the training emphasis should lie on a fast computation or on a high robustness. Default: "speed"</param>
		/// <param name="ambiguityCriterion">Criterion for solving ambiguous matches of the initial components in the training images. Default: "rigidity"</param>
		/// <param name="maxContourOverlap">Maximum contour overlap of the found initial components in a training image. Default: 0.2</param>
		/// <param name="clusterThreshold">Threshold for clustering the initial components. Default: 0.5</param>
		/// <returns>Contour regions of rigid model components.</returns>
		// Token: 0x060003AB RID: 939 RVA: 0x00016004 File Offset: 0x00014204
		public HRegion TrainModelComponents(HImage modelImage, HRegion initialComponents, HImage trainingImages, HTuple contrastLow, HTuple contrastHigh, HTuple minSize, HTuple minScore, HTuple searchRowTol, HTuple searchColumnTol, HTuple searchAngleTol, string trainingEmphasis, string ambiguityCriterion, double maxContourOverlap, double clusterThreshold)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1017);
			HalconAPI.Store(proc, 1, modelImage);
			HalconAPI.Store(proc, 2, initialComponents);
			HalconAPI.Store(proc, 3, trainingImages);
			HalconAPI.Store(proc, 0, contrastLow);
			HalconAPI.Store(proc, 1, contrastHigh);
			HalconAPI.Store(proc, 2, minSize);
			HalconAPI.Store(proc, 3, minScore);
			HalconAPI.Store(proc, 4, searchRowTol);
			HalconAPI.Store(proc, 5, searchColumnTol);
			HalconAPI.Store(proc, 6, searchAngleTol);
			HalconAPI.StoreS(proc, 7, trainingEmphasis);
			HalconAPI.StoreS(proc, 8, ambiguityCriterion);
			HalconAPI.StoreD(proc, 9, maxContourOverlap);
			HalconAPI.StoreD(proc, 10, clusterThreshold);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			HalconAPI.UnpinTuple(contrastLow);
			HalconAPI.UnpinTuple(contrastHigh);
			HalconAPI.UnpinTuple(minSize);
			HalconAPI.UnpinTuple(minScore);
			HalconAPI.UnpinTuple(searchRowTol);
			HalconAPI.UnpinTuple(searchColumnTol);
			HalconAPI.UnpinTuple(searchAngleTol);
			num = base.Load(proc, 0, num);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(modelImage);
			GC.KeepAlive(initialComponents);
			GC.KeepAlive(trainingImages);
			return result;
		}

		/// <summary>
		///   Train components and relations for the component-based matching.
		///   Modified instance represents: Handle of the training result.
		/// </summary>
		/// <param name="modelImage">Input image from which the shape models of the initial components should be created.</param>
		/// <param name="initialComponents">Contour regions or enclosing regions of the initial components.</param>
		/// <param name="trainingImages">Training images that are used for training the model components.</param>
		/// <param name="contrastLow">Lower hysteresis threshold for the contrast of the initial components in the image. Default: "auto"</param>
		/// <param name="contrastHigh">Upper hysteresis threshold for the contrast of the initial components in the image. Default: "auto"</param>
		/// <param name="minSize">Minimum size of connected contour regions. Default: "auto"</param>
		/// <param name="minScore">Minimum score of the instances of the initial components to be found. Default: 0.5</param>
		/// <param name="searchRowTol">Search tolerance in row direction. Default: -1</param>
		/// <param name="searchColumnTol">Search tolerance in column direction. Default: -1</param>
		/// <param name="searchAngleTol">Angle search tolerance. Default: -1</param>
		/// <param name="trainingEmphasis">Decision whether the training emphasis should lie on a fast computation or on a high robustness. Default: "speed"</param>
		/// <param name="ambiguityCriterion">Criterion for solving ambiguous matches of the initial components in the training images. Default: "rigidity"</param>
		/// <param name="maxContourOverlap">Maximum contour overlap of the found initial components in a training image. Default: 0.2</param>
		/// <param name="clusterThreshold">Threshold for clustering the initial components. Default: 0.5</param>
		/// <returns>Contour regions of rigid model components.</returns>
		// Token: 0x060003AC RID: 940 RVA: 0x0001611C File Offset: 0x0001431C
		public HRegion TrainModelComponents(HImage modelImage, HRegion initialComponents, HImage trainingImages, int contrastLow, int contrastHigh, int minSize, double minScore, int searchRowTol, int searchColumnTol, double searchAngleTol, string trainingEmphasis, string ambiguityCriterion, double maxContourOverlap, double clusterThreshold)
		{
			this.Dispose();
			IntPtr proc = HalconAPI.PreCall(1017);
			HalconAPI.Store(proc, 1, modelImage);
			HalconAPI.Store(proc, 2, initialComponents);
			HalconAPI.Store(proc, 3, trainingImages);
			HalconAPI.StoreI(proc, 0, contrastLow);
			HalconAPI.StoreI(proc, 1, contrastHigh);
			HalconAPI.StoreI(proc, 2, minSize);
			HalconAPI.StoreD(proc, 3, minScore);
			HalconAPI.StoreI(proc, 4, searchRowTol);
			HalconAPI.StoreI(proc, 5, searchColumnTol);
			HalconAPI.StoreD(proc, 6, searchAngleTol);
			HalconAPI.StoreS(proc, 7, trainingEmphasis);
			HalconAPI.StoreS(proc, 8, ambiguityCriterion);
			HalconAPI.StoreD(proc, 9, maxContourOverlap);
			HalconAPI.StoreD(proc, 10, clusterThreshold);
			HalconAPI.InitOCT(proc, 0);
			HalconAPI.InitOCT(proc, 1);
			int num = HalconAPI.CallProcedure(proc);
			num = base.Load(proc, 0, num);
			HRegion result;
			num = HRegion.LoadNew(proc, 1, num, out result);
			HalconAPI.PostCall(proc, num);
			GC.KeepAlive(this);
			GC.KeepAlive(modelImage);
			GC.KeepAlive(initialComponents);
			GC.KeepAlive(trainingImages);
			return result;
		}
	}
}
